import 'dart:io';

void main() async {
  print('🔧 修复撇号问题...');
  
  final filesToFix = [
    'lib/data/esperanto_mega_vocabulary.dart',
    'lib/data/esperanto_vocabulary_batch2.dart',
  ];
  
  for (final filePath in filesToFix) {
    print('修复文件: $filePath');
    await fixApostrophes(filePath);
  }
  
  print('✅ 修复完成！');
}

Future<void> fixApostrophes(String filePath) async {
  final file = File(filePath);
  if (!await file.exists()) {
    print('❌ 文件不存在: $filePath');
    return;
  }
  
  String content = await file.readAsString();
  
  // 修复撇号问题，将 ' 替换为 \'
  content = content
    .replaceAll("Don']t", "Don\\'t")
    .replaceAll("I don']t", "I don\\'t")
    .replaceAll("doesn']t", "doesn\\'t")
    .replaceAll("can']t", "can\\'t")
    .replaceAll("won']t", "won\\'t")
    .replaceAll("isn']t", "isn\\'t")
    .replaceAll("aren']t", "aren\\'t")
    .replaceAll("wasn']t", "wasn\\'t")
    .replaceAll("weren']t", "weren\\'t")
    .replaceAll("haven']t", "haven\\'t")
    .replaceAll("hasn']t", "hasn\\'t")
    .replaceAll("hadn']t", "hadn\\'t")
    .replaceAll("wouldn']t", "wouldn\\'t")
    .replaceAll("shouldn']t", "shouldn\\'t")
    .replaceAll("couldn']t", "couldn\\'t");
  
  await file.writeAsString(content);
  print('✅ 已修复: $filePath');
} 